package com.open.capacity.controller;

import com.open.capacity.common.entity.RegionModel;
import com.open.capacity.common.web.Result;
import com.open.capacity.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/business/address")
public class AddressController {

    @Autowired
    private AddressService addressService;
//获取省份地址
    @GetMapping("/GetAllProvince")
    public Result GetAllProvince(){
        List<RegionModel> allProvince = addressService.GetAllProvince();
        return Result.succeed(allProvince,"所有省份地址");
    }
//获取市区地址
    @GetMapping("/GetAreaByID")
        public Result GetAreaByID(Integer id){
        List<RegionModel> areaByID = addressService.GetAreaByID(id);
        return Result.succeed(areaByID,"获取市区地址");
    }
//获取县地址
    @GetMapping("/GetCountyByID")
    public Result GetCountyByID(Integer id){
        List<RegionModel> allProvince = addressService.GetCountyByID(id);
        return Result.succeed(allProvince,"获取市区地址");
    }
//获取用户省份地址 通过 ID
    @GetMapping("/GetProvinceByUserID")
    public Result GetProvinceByUserID(Integer id){
        List<RegionModel> allProvince = addressService.GetProvinceByUserID(id);
        return Result.succeed(allProvince,"获取用户省份地址");
    }
//获取用户市地址 通过 ID
    @GetMapping("/GetAreaByUserID")
    public Result GetAreaByUserID(Integer id){
        List<RegionModel> allProvince = addressService.GetAreaByUserID(id);
        return Result.succeed(allProvince,"获取用户市地址");
    }
//获取用户区地址 通过 ID
    @GetMapping("/GetCountyByUserID")
    public Result GetCountyByUserID(Integer id){
        List<RegionModel> allProvince = addressService.GetCountyByUserID(id);
        return Result.succeed(allProvince,"获取用户区地址");
    }

}
